package com.aidex.biz.service.impl;

import com.aidex.biz.domain.HousingInfo;
import com.aidex.biz.mapper.HousingInfoMapper;
import com.aidex.biz.service.HousingInfoService;
import com.aidex.common.annotation.DataScope;
import com.aidex.common.core.service.BaseServiceImpl;
import com.aidex.common.utils.NumberUtils;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 小区信息Service业务层处理
 *
 * @author sean
 * @email 2074844820@qq.com
 * @date 2022-09-23
 */
@Service
@Transactional(readOnly = true)
public class HousingInfoServiceImpl extends BaseServiceImpl<HousingInfoMapper, HousingInfo> implements HousingInfoService {
    private static final Logger log = LoggerFactory.getLogger(HousingInfoServiceImpl.class);

    /**
     * 获取单条数据
     *
     * @param housingInfo 小区信息
     * @return 小区信息
     */
    @Override
    public HousingInfo get(HousingInfo housingInfo) {
        HousingInfo dto = super.get(housingInfo);
        return dto;
    }

    /**
     * 获取单条数据
     *
     * @param id 小区信息id
     * @return 小区信息
     */
    @Override
    public HousingInfo get(String id) {
        HousingInfo dto = super.get(id);
        return dto;
    }


    /**
     * 查询小区信息列表
     *
     * @param housingInfo 小区信息
     * @return 小区信息
     */
    @Override
    @DataScope(userAlias = "a", deptAlias = "a")
    public List<HousingInfo> findList(HousingInfo housingInfo) {
        return super.findList(housingInfo);
    }

    /**
     * 分页查询小区信息列表
     *
     * @param housingInfo 小区信息
     * @return 小区信息
     */
    @Override
    @DataScope(userAlias = "a", deptAlias = "a")
    public PageInfo<HousingInfo> findPage(HousingInfo housingInfo) {
        return super.findPage(housingInfo);
    }

    /**
     * 保存小区信息
     *
     * @param housingInfo
     * @return 结果
     */
    @Override
    public boolean save(HousingInfo housingInfo) {

        return super.save(housingInfo);
    }


    /**
     * 删除小区信息信息
     *
     * @param housingInfo
     * @return 结果
     */
    @Override
    public boolean remove(HousingInfo housingInfo) {
        return super.remove(housingInfo);
    }

    /**
     * 批量删除小区信息
     *
     * @param ids 需要删除的小区信息ID
     * @return 结果
     */
    @Transactional(readOnly = false)
    @Override
    public int deleteHousingInfoByIds(String[] ids) {
        return mapper.deleteHousingInfoByIds(ids);
    }

    /**
     * 获取最大编号
     *
     * @param housingInfo 小区信息
     * @return 结果
     */
    @Override
    public int findMaxSort(HousingInfo housingInfo) {
        return NumberUtils.nextOrder(mapper.findMaxSort(housingInfo));
    }

    @Override
    public Map<String, String> getIndexInfo(HousingInfo housingInfo) {
        return mapper.getIndexInfo(housingInfo);
    }
}
